package com.monolithiot.sso.common.entity;

import com.monolithiot.sso.common.context.Constants;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * 2018/12/30 Create by 郭文梁
 * UserGroupRole
 * 用户组角色实体类
 *
 * @author 郭文梁
 * @date 2018/12/30
 */
@Data
@Table(name = "tb_user_group_role")
public class UserGroupRole {
    /**
     * 角色：群主
     */
    public static final int ROLE_MASTER = 0;
    /**
     * 角色名称：群主
     */
    public static final String ROLE_MASTER_NAME = "群主";
    /**
     * 状态 刚创建 管理员还未处理
     */
    public static final int STATE_CREATE = 0x00;
    /**
     * 状态 管理员已同意加入用户组
     */
    public static final int STATE_PASS = 0x01;
    /**
     * 状态 管理员不同意加入用户组
     */
    public static final int STATE_NOT_PASS = 0x02;
    /**
     * id            INT(10)      NOT NULL AUTO_INCREMENT
     * COMMENT '主键ID',
     * PRIMARY KEY (id)
     */
    @Id
    @GeneratedValue(generator = Constants.SQL.GENERATOR_JDBC)
    @Column(name = "id", length = 10, nullable = false)
    private Integer id;
    /**
     * user_id       INT(10)      NOT NULL
     * COMMENT '用户ID',
     */
    @Column(name = "user_id", length = 10, nullable = false)
    private Integer userId;
    /**
     * 用户实体对象
     */
    private User user;
    /**
     * user_group_id INT(10)      NOT NULL
     * COMMENT '用户组ID',
     */
    @Column(name = "user_group_id", length = 10, nullable = false)
    private Integer userGroupId;
    /**
     * 用户组实体对象
     */
    private UserGroup userGroup;
    /**
     * 角色等级，登记数值越大表示用户权限越低
     * 创建者的role_level为0
     * role_level    INT(2)       null
     * COMMENT '角色',
     */
    @Column(name = "role_level", length = 2)
    private Integer roleLevel;
    /**
     * role_name     VARCHAR(100) null
     * COMMENT '角色名称',
     */
    @Column(name = "role_name", length = 100)
    private String roleName;
    /**
     * state         INT(2)       NOT NULL DEFAULT 0
     * COMMENT '状态',
     */
    @Column(name = "state", length = 2, nullable = false)
    private Integer state;
}
